﻿/*
 * Copyright(C) 2012,ajayumi 保留所有权利。( All rights reserved. )
 * 
 * 文件名称：ListUserControlMultiControls.cs
 * 摘    要：
 * 当前版本：1.0
 * 作    者：黄乙冬 (ajayumi)
 * 创建日期：2012年5月24日
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace ajayumi.Platform.Web
{
    public class ListUserControlMultiControls : ListUserControlBase
    {
        #region Variables

        #endregion

        #region Properties

        /// <summary>
        /// 用于显示数据的服务器控件ID的集合
        /// </summary>
        public virtual string[] ListControlIDs
        {
            get
            {
                return new string[] { "dlSlide", "gvSlide" };
            }
        }

        #endregion

        public override string ClientID
        {
            get
            {
                return "__ListUserControlMultiControls";
            }
        }

        protected override void BindData()
        {
            int rowCount = 0;
            ICollection collection = this.GetBindDataObject(ref rowCount);

            DataList dlCon = null;
            GridView gvCon = null;
            Repeater rpCon = null;
            foreach (string item in this.ListControlIDs)
            {
                //绑定数据源控件
                Control control = this.DataControl.FindControl(item);
                if (control is DataList)
                {
                    dlCon = control as DataList;
                    dlCon.ItemDataBound += new DataListItemEventHandler(DataList_ItemDataBound);
                    dlCon.DataSource = collection;
                    dlCon.DataBind();
                }
                else if (control is GridView)
                {
                    gvCon = control as GridView;
                    gvCon.RowDataBound += new GridViewRowEventHandler(GridView_RowDataBound);
                    gvCon.DataSource = collection;
                    gvCon.DataBind();
                }
                else if (control is Repeater)
                {
                    rpCon = control as Repeater;
                    rpCon.ItemDataBound += new RepeaterItemEventHandler(Repeater_ItemDataBound);
                    rpCon.DataSource = collection;
                    rpCon.DataBind();
                }
            }

            this.RowCount = rowCount;//更新总记录数
            this.PageCount = HtmlHelper.CalcTotalPartNumber(rowCount, this.PageSize);

            UpdatePaginationStatus();
            CreateDigitPageNavigation();
            Basic_DataBoundComplete();
        }


        protected virtual void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //throw new NotImplementedException();
        }

        protected virtual void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //throw new NotImplementedException();
        }

        protected virtual void DataList_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            //throw new NotImplementedException();
        }


    }
}
